<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
    
    	<%@ page import="org.hibernate.SessionFactory"%>
<%@ page import="org.hibernate.Session"%>
<%@ page import="java.util.List"%>
<%@ page import="hibernate.model.*"%>
<%@ page import="hibernate.util.HibernateUtil"%>
<%@ page import="hibernate.method.*"%>
<%@ page import="hibernate.method.UserMethods"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<script src="../js/jquery-1.10.2.min.js"></script>
  </head>
  <body>
<div id="content">

<%
SessionFactory sessionFactory = HibernateUtil
								.getSessionAnnotationFactory();
						Session s = sessionFactory.openSession();
						s.beginTransaction();
						InvitationMethods inv_m = new InvitationMethods();
						 Integer user_id = (Integer) session.getAttribute("user_id");
							UserMethods u_m = new UserMethods();
							LocalMethods lm = new LocalMethods();
							GameMethods game = new GameMethods();
							//User u = u_m.id_to_user(sessionFactory, s, user_id);
							List<Game> games = game.listAllGames(sessionFactory, s);
							%>
							
<form action="../editAssortment" method="POST" name='form1'>							
<table>
<tr>
<td>
Lokal:
</td>
<td>
		<% List<Local> locals = lm.listAllLocals(sessionFactory, s); 
				if (locals.size() > 0) {%> 
			<select id="local" name="local" style="width:300px;">
			<% 	for (Local c : locals) {
					int id = c.getLocal_id();
					String catname = c.getCountry()+", "+ c.getCity()+", "+ c.getStreet()+" "+c.getLocal_number();%>
			<option value="<%=id%>"><%=catname%></option>
			<%}
				
			}
			if (locals.size() == 0) {
		 out.println("Nie ma zadnych lokali w bazie");
		
			} %>
			</select>
</td>
</tr>

<tr>
<td>
Gra:
</td>
<td>
		<select id="game1" name="game1">
						<%	if (games.size() > 0) {
							for (Game g : games) {
								String gamename = g.getName();
								int id = g.getGame_id();%>
						<option value="<%=id%>"><%=gamename%></option>
						<%}
							
						}
						if (games.size() == 0) {
					 out.println("Nie ma zadnych kategorii w bazie");
					
						} %>
						</select>
</td>
</tr>

<tr>
<td>
Ilosc:
</td>
<td>
<input type="number" id="howmany" name="howmany" value="1"/>
</td>
</tr>


			<tr>
				<td><input type="submit" class="mainBtn" value="Edytuj Asortyment" /></td>
			</tr>

</table>
</form>

  </div>
  </body>
  </html>
  